package com.haiqiu.tools.test.controller;

import com.haiqiu.tools.qrcode.utils.QRCodeUtils;
import com.haiqiu.tools.word.utils.WordUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.swing.filechooser.FileSystemView;
import java.io.File;
import java.util.HashMap;
import java.util.Map;

/**
 * @author HaiQiu
 * @date 2022/9/27
 * 二维码生成
 */
@RestController
@RequestMapping("/qrcode")
public class QrCodeController {

    @RequestMapping("/create")
    public String create() throws Exception {
        String text = "http://www.baidu.com";  //这里设置自定义网站url
        String logoPath = "http://221.182.8.141:10090/static/img/tubiao.db87f024.png";
        //当前用户桌面路径
        File desktopDir = FileSystemView.getFileSystemView().getHomeDirectory();
        String desktopPath = desktopDir.getAbsolutePath();
        System.out.println("desktopPath = " + desktopPath);
        System.out.println(QRCodeUtils.encode(text, logoPath, desktopPath, true));
        return "生成成功";
    }

    @RequestMapping("/export")
    public String export() throws Exception {
        String text = "http://www.baidu.com";  //这里设置自定义网站url
        String logoPath = "http://221.182.8.141:10090/static/img/tubiao.db87f024.png";
        QRCodeUtils.encodeExport(text, logoPath, true);
        return "生成成功";
    }
}
